package com.jd.sunny.java.collection;

import java.util.*;

/**
 * @Description:
 * @author:sunlin
 * @since:2012-12-07 11:02
 * @version:1.0.0
 */
public class TestBatchOperation {

    public static void main(String[] args){

        //get intersection without iterator
        Set<String> a = new HashSet<String>();
        a.add("sunlin");
        a.add("xiaozhi");
        a.add("qiushibaike");

        Set<String> b = new HashSet<String>();
        b.add("sunlin");
        b.add("xiaozhi");
        b.add("maopu");

        Set<String> set = new HashSet<String>(a);
        set.retainAll(b);

        System.out.println(set);

        //get son list
        List<String> list = new ArrayList<String>();
        list.add("a");
        list.add("b");
        list.add("c");

        List<String> sonList = list.subList(0,2);

        //we can operate sonList,it also infulence father list
        System.out.println(sonList);
        sonList.add("d");
        sonList.remove("a");

        System.out.println("sonList=" + sonList);
        System.out.println("list=" + list);

    }
}
